﻿using System.Data.Entity.ModelConfiguration;

using NeGroid.ChampionshipManager.Core;

namespace NeGroid.ChampionshipManager.Persistance.Mappings
{
	public class SubstitionMap : EntityTypeConfiguration<Substition>
	{
		public SubstitionMap()
		{
			HasKey(t => 
				new 
				{ 
					t.GameInfoId, 
					t.PlayerInId, 
					t.PlayerOutId, 
					t.Date 
				});

			Property(t => t.Timestamp)
				.IsConcurrencyToken();

			HasRequired(t => t.PlayerIn)
				.WithMany()
				.HasForeignKey(t => t.PlayerInId)
				.WillCascadeOnDelete(false);
			HasRequired(t => t.PlayerOut)
				.WithMany()
				.HasForeignKey(t => t.PlayerOutId)
				.WillCascadeOnDelete(false);
		}
	}
}
